﻿using Model;
using Business.IFace;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MB.Orm.DB;
using Public.DataAccess;
using MB.RuleBase.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Business
{
    public class BShelves
    {

        public List<OffShelves> GetOffShelvesList(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OffShelves> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<OffShelves>
                                                ("Shelves", "GetOffShelves", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        public int DeleteOffShelves(int OffShelvesID)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery("Shelves", "DeleteOffShelves", OffShelvesID);
        }

        public int AddOffShelves(OffShelves offShelves)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<OffShelves>
                            ("Shelves", "AddOffShelves", offShelves);
        }
        public int EditOffShelvesByID(OffShelves offShelves)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<OffShelves>
                            ("Shelves", "EditOffShelvesByID", offShelves);
        }

        public OffShelves CheckOffShelvesPrimary(int GOODSID, string BatchNo,DateTime OFFSHELVESDATE, string OFFSHELVESID)
        {
            OFFSHELVESID = string.IsNullOrEmpty(OFFSHELVESID) ? "0" : OFFSHELVESID;
            OffShelves Info = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OffShelves>("Shelves", "CheckOffShelvesPrimary"
                , GOODSID, BatchNo,OFFSHELVESDATE, int.Parse(OFFSHELVESID)).FirstOrDefault();
            return Info;
        }

        public List<OffShelves> CheckOffShelvesPrimary(int GOODSID, DateTime OFFSHELVESDATE)
        {
            List<OffShelves> Info = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OffShelves>("Shelves", "CheckOffShelvesPrimary"
                , GOODSID, OFFSHELVESDATE);
            return Info;
        }
    }
}
